import axios from 'axios'
import { message } from 'antd'
const service = axios.create({
  baseURL: '',
  timeout: 10000,
})
service.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)

service.interceptors.response.use(
  (response) => {
    return response.data
  },
  (error) => {
    //全局拦截
    if (error.response.status === 404) {
      message.error('请求的路径不存在')
    } else if (error.response.status === 500) {
      message.error('服务器内部错误')
    }
    return Promise.reject(error)
  }
)
export default service
